# This is a sample Python script.
#
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
#

# def print_hi(name):
#     # Use a breakpoint in the code line below to debug your script.
#     print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.
#
#
# # Press the green button in the gutter to run the script.
# if __name__ == '__main__':
#     print_hi('PyCharm')
#
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
#

#
# import matplotlib
# import pandas as pd
# import networkx as nx
# import matplotlib.pyplot as plt
#
# matplotlib.use('TkAgg')
# plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
#
# vertices = pd.read_csv("part2.csv")
# edges = pd.read_csv("part1.csv")
#
# G = nx.DiGraph()
# for _, row in vertices.iterrows():
#     G.add_node(row['id'], name=row['name'])
# for _, row in edges.iterrows():
#     G.add_edge(row['src'], row['dst'], label=row['relationship'])
#
# plt.figure(figsize=(12, 8))
# pos = nx.spring_layout(G)
# labels = {node: data['name'] for node, data in G.nodes(data=True)}
# edge_labels = {(u, v): d['label'] for u, v, d in G.edges(data=True)}
#
# nx.draw_networkx_nodes(G, pos, node_size=2000, node_color='lightblue')
# nx.draw_networkx_edges(G, pos, arrowstyle='->', arrowsize=20)
# nx.draw_networkx_labels(G, pos, labels=labels, font_size=12)
# nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels)
# plt.title("Social Network Analysis")
# plt.axis('off')
# plt.show()


#class0523
# import matplotlib.pyplot as plt
# plt.rcParams['font.san-serif'] = ['SimHei']
# plt.rcParams['axes.unicode_minus'] = False
# #1.绘制清远市未来15天的最低温和最高温折线
# min_temps = [22, 23, 24, 25, 24, 25, 24, 23, 22, 23, 24, 25, 24, 23, 22]
# max_temps = [29, 30, 31, 32, 33, 34, 31, 30, 29, 30, 32, 33, 31, 30, 29]
# #2.添加未来15天降水量柱状图
# precipitation = [3.2, 5.1, 0.0, 0.5, 8.7, 15.4, 12.3, 2.1, 0.0, 1.2, 6.8, 20.1, 7.5, 3.0, 0.2]
# #3.绘制2025年国内热门游戏排行饼状图
# # labels = ['王者荣耀', '原神', '和平精英', '金铲铲之战', '第五人格', '开心消消乐','贪吃蛇大 作战','其他']
# # shares = [35, 20, 12, 10, 8, 6, 5, 4]
# #1.折线图介绍
# plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
# plt.plot([a for a in range(1000)], [b*b for b in range(1000)])  # 绘制y=x^2在第一象限的部分
# plt.xlabel('value x')
# plt.ylabel('value y')

#2.示例——使用折线图绘制温度曲线
# %matplotlib inline
# import matplotlib.pyplot as plt  # 导入pyplot模块
# plt.rcParams['font.sans-serif'] = ['SimHei']  # 解决中文乱码问题
# plt.rcParams['axes.unicode_minus'] = False

# months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
# temps = [-3, 0, 8, 15, 22, 26, 28, 27, 21, 14, 5, -1]
# plt.plot(months, temps)
# plt.xlabel("月份")
# plt.ylabel("温度（单位：℃）")
# plt.title("北京市全年逐月平均温度")

# #4-3-3 平均温度曲线绘制
# months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
# temps = [-3, 0, 8, 15, 22, 26, 28, 27, 21, 14, 5, -1]
# plt.ﬁgure(ﬁgsize=(16, 4), dpi=150)
# plt.grid(linestyle=":", alpha=0.5)
# plt.plot(months, temps)
# plt.xlabel("月份")
# plt.ylabel("温度（单位：℃）")
# plt.title("北京市全年逐月平均温度")
#
#4-3-4 优化平均温度曲线
# months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']  # 准备月份信息
# max_temps = [2, 6, 14, 21, 28, 31, 32, 31, 26, 19, 10, 4]
# min_temps = [-7, -5, 2, 9, 16, 20, 24, 22, 17, 9, 1, -5]  # 准备平均最低温度数据
# plt.figure(figsi=(16, 4), dpi=150)
# plt.grid(linestyle=":", alpha=0.5)  # 添加画布网格
# plt.xlabel("月份")
# plt.ylabel("温度（单位：℃）")  # 添加y轴标签
# plt.title("北京市全年逐月平均最高/最低温度")
# plt.plot(months, max_temps, color="r", label="平均最高温度")  # 绘制平均最高温度折线图
# plt.plot(months, min_temps, color="b", label="平均最低温度")  # 绘制平均最低温度折线图
# plt.legend()
# plt.savefig('temp.png')
# plt.show()

#4-3-5 同时绘制两条折线
# max_temps = [2, 6, 14, 21, 28, 31, 32, 31, 26, 19, 10, 4]  # 准备平均最高温度数据
# min_temps = [-7, -5, 2, 9, 16, 20, 24, 22, 17, 9, 1, -5]
# plt.plot(months, max_temps, color="r", label="平均最高温度")  # 绘制平均最高温度折线图
# plt.plot(months, min_temps, color="b", label="平均最低温度")




# import matplotlib.pyplot as plt
# plt.rcParams['font.sans-serif'] = ['SimHei']
# plt.rcParams['axes.unicode_minus'] = False
#
# plt.bar([1, 2, 3, 4], [1, 4, 9, 16])
# name_list = ['核桃', '巧克力', '饼干', '奶酪', '鸭肉', '鸡蛋', '玉米', '香蕉', '豆腐', '苹果', '梨', '白菜', '黄瓜', '番茄']
# calorie_list = [646, 589, 435, 328, 240, 144, 112, 93, 87, 53, 51, 20, 16, 15]
# plt.figure(figsize=(12, 6), dpi=150)
# x = range(len(name_list))
# plt.xticks(x, name_list)
# plt.bar(x, calorie_list, width=0.4, color=['#ffaa00' if i>300 else '#40c000' for i in calorie_list])
# plt.title("常见食物热量柱状图")
# plt.xlabel("食物名")
# plt.ylabel("热量（单位：大卡/100克）")
# plt.grid(linestyle="--", alpha=0.2)
# x = range(len(name_list))
# plt.xticks(x, name_list)


#0530人脸识别
# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.


# def print_hi(name):
#     # Use a breakpoint in the code line below to debug your script.
#     print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.
#
#
# # Press the green button in the gutter to run the script.
# if __name__ == '__main__':
#     print_hi('PyCharm')

# See PyCharm help at https://www.jetbrains.com/help/pycharm/

# import cv2
# img = cv2.imread('1.PNG',1)
# face_engine = cv2.CascadeClassiﬁer(cv2.data.haarcascades+'haarcascade_frontalface_default.xml')
# faces = face_engine.detectMultiScale(img,scaleFactor=1.3,minNeighbors=5)
# for (x,y,w,h) in faces:
#     img = cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
#     cv2.imshow('img', img)
#     cv2.waitKey(0)
#     cv2.destroyAllWindows()
#     cv2.immrite('output.PNG',img)


# import cv2
# face_cascade = cv2.CascadeClassiﬁer(cv2.data.haarcascades+'haarcascade_frontalface_default.xml')
# eye_cascade = cv2.CascadeClassiﬁer(cv2.data.haarcascades+'haarcascade_eye.xml')
# smile_cascade = cv2.CascadeClassiﬁer(cv2.data.haarcascades + 'haarcascade_smile.xml')
# img = cv2.imread('2.PNG')
# faces = face_cascade.detectMultiScale(img, 1.3, 5)
# for (x, y, w, h) in faces:
#     img = cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
#     face_area = img[y:y + h, x:x + w]
#     eyes = eye_cascade.detectMultiScale(face_area)
#     for (ex, ey, ew, eh) in eyes:
#         cv2.rectangle(face_area, (ex, ey), (ex + ew, ey + eh), (0, 255, 0), 1)
#
#     smiles = smile_cascade.detectMultiScale(face_area, scaleFactor=1.16, minNeighbors=65, minSize=(25, 25),ﬂags=cv2.CASCADE_SCALE_IMAGE)
#     for (ex, ey, ew, eh) in smiles:
#         cv2.rectangle(face_area, (ex, ey), (ex + ew, ey + eh), (0, 0, 255), 1)
#         cv2.putText(img, 'Smile', (x, y - 7), 3, 1.2, (0, 0, 255), 2, cv2.LINE_AA)
# cv2.imshow('frame2', img)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
# cv2.imwrite('output.jpg', img)






# import cv2
# face_cascade = cv2.CascadeClassiﬁer(cv2.data.haarcascades+'haarcascade_frontalface_default.xml')
# eye_cascade = cv2.CascadeClassiﬁer(cv2.data.haarcascades+'haarcascade_eye.xml')
# smile_cascade = cv2.CascadeClassiﬁer(cv2.data.haarcascades+'haarcascade_smile.xml')
# cap = cv2.VideoCapture(0)
# while(True):
#     ret, frame = cap.read()
#     faces = face_cascade.detectMultiScale(frame, 1.3, 2)
#     img = frame
#     for (x, y, w, h) in faces:
#         img = cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
#         face_area = img[y:y + h, x:x + w]
#         eyes = eye_cascade.detectMultiScale(face_area, 1.3, 10)
#         for (ex, ey, ew, eh) in eyes:
#             cv2.rectangle(face_area, (ex, ey), (ex + ew, ey + eh), (0, 255, 0), 1)
#             smiles = smile_cascade.detectMultiScale(face_area, scaleFactor=1.16, minNeighbors=65, minSize=(25, 25),ﬂags=cv2.CASCADE_SCALE_IMAGE)
#             for (ex, ey, ew, eh) in smiles:
#                 cv2.rectangle(face_area, (ex, ey), (ex + ew, ey + eh), (0, 0, 255), 1)
#                 cv2.putText(img, 'Smile', (x, y - 7), 3, 1.2, (0, 0, 255), 2, cv2.LINE_AA)
#                 cv2.imshow('frame2', img)
#                 if cv2.waitKey(5) & 0xFF == ord('q'):
#                     break
#                     cap.release()
#                     cv2.destroyAllWindows()

